package pl.com.qapps.datastore.berkeley;

import java.util.Iterator;

public abstract class IterableWrapper<W, T> implements Iterable<T> {

	private Iterable<W> wrapped;

	public IterableWrapper(Iterable<W> wrapped) {
		super();
		this.wrapped = wrapped;
	}

	protected abstract T wrap(W item);

	@Override
	public Iterator<T> iterator() {
		return new IteratorWrapper<W, T>(wrapped.iterator()) {

			@Override
			protected T wrap(W item) {
				return IterableWrapper.this.wrap(item);
			}

		};
	}

}
